package com.zhenyi.tuangou.admin.index;

import com.utils.AESUtils;
import com.utils.AuthUtils;

public class AuthController extends AdminController {
	
	private final String AES_KEY = "tuangou@#$&*,.<>";

	public void login() {
		final String ADMIN_ACCOUNT = "admin";
		final String ADMIN_PASSWORD = "admin";
		String uid = "shanxiaojie";
		String account = getPara("account");
		String password = AESUtils.decrypt(AES_KEY, getPara("password"));
		if (!ADMIN_ACCOUNT.equals(account)) {
			renderFailure();
			return;
		}
		if (!ADMIN_PASSWORD.equals(password)) {
			renderFailure();
			return;
		}
		String token = AuthUtils.login(uid, this);
		renderSuccess(token);
	}

	public void logout() {
		AuthUtils.logout(this);
		renderSuccess();
	}
}
